Skip to content

test(engine): cover remaining directives.go branches and remove dead code#1

Merged
matuszeg merged 1 commit intofeat/nomutant-directivefrom
coverage/directives-100pct
Apr 29, 2026
Merged

test(engine): cover remaining directives.go branches and remove dead code#1
matuszeg merged 1 commit intofeat/nomutant-directivefrom
coverage/directives-100pct

Conversation

@matuszeg
Copy link
Copy Markdown
Owner

Summary

Internal review branch addressing the four lines Codecov flagged on internal/engine/directives.go (lines 68, 168, 214, 268 of the version on feat/nomutant-directive@1ca72c6).

  • Line 68 — nil-receiver guard in isSuppressed. Now exercised by TestDirectiveIndex_NilReceiverIsSafe, which calls (*directiveIndex)(nil).isSuppressed(...) and confirms it returns false without panicking.
  • Line 168continue inside the comma-split loop in parseDirective, hit when an empty entry appears (e.g. //nomutant:arithmetic-base,,invert-bitwise). Now exercised by TestBuildDirectiveIndex_TypedFilterWithEmptyEntries.
  • Lines 214 and 268*ast.Comment guards inside collectTokenLines and largestNodeStartingAtLine. Removed as unreachable: the preceding *ast.CommentGroup guard already returns false from the ast.Inspect callback, so the walker never descends into the CommentGroup's *ast.Comment children. Added a comment explaining why no Comment guard is needed.

Test plan

  • go test -race ./internal/engine/... — all green
  • make lint — 0 issues
  • go tool cover -func on directives.go — every function reports 100.0%

If this looks good, merging it into feat/nomutant-directive will update the real PR (go-gremlins#279) with the coverage and dead-code fixes.

…code

Codecov flagged four uncovered lines in internal/engine/directives.go.
Two of them were genuinely missing tests — the nil-receiver guard in
isSuppressed and the empty-name "continue" inside parseDirective's
comma-split loop — and are now exercised by new unit tests. The other
two were a *ast.Comment guard inside both collectTokenLines and
largestNodeStartingAtLine that turn out to be unreachable, because
the preceding *ast.CommentGroup guard already returns false from the
ast.Inspect callback and ast.Inspect therefore never descends into
the CommentGroup's *ast.Comment children. Removed both as dead code
and noted in a comment why no Comment guard is needed.
@matuszeg matuszeg merged commit adddf29 into feat/nomutant-directive Apr 29, 2026
@matuszeg matuszeg deleted the coverage/directives-100pct branch April 29, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant